package com.spark.lola.logistics.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.spark.lola.logistics.entity.ExpensesInfo;
import com.spark.lola.logistics.entity.OrderInfo;
import com.spark.lola.logistics.vo.MatchToOrderLocationVo;
import com.spark.lola.logistics.vo.OrderCountStatisticVo;
import com.spark.lola.logistics.vo.OrderInfoVo;
import com.spark.lola.logistics.vo.OrderStatisticVo;
import com.spark.lola.support.core.vo.SelectMap;
import com.spark.lola.support.common.entity.ShiroUser;
import com.spark.lola.support.mybatis.entity.QueryParam;
import com.spark.lola.support.mybatis.service.BaseService;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author: Zhi-peng wang
 * @date: 2020/04/27 16:03
 * 货运单业务接口
 **/
@Transactional
public interface LogisticsOrderInfoService extends BaseService<OrderInfo> {

    IPage<OrderInfoVo> findPage(QueryParam<OrderInfoVo> queryParam);

    /**
     * @description: 获取货运单详情（货运单信息，货运单商品信息，货运单流程信息）
     * @param: orderId 货运单id
     * @return: JSONObject 总信息封装
     * @author: wzp
     * @date: 2020/4/28
     */
    OrderInfo findInfo(long orderId) throws Exception;

    MatchToOrderLocationVo matchToOrderLocation(long createId);

    /**
     * @description: 创建/修改货运单
     * @param: orderInfo 货运单信息
     * @return: ResponseBean 统一响应
     * @author: wzp
     * @date: 2020/4/29
     */
    OrderInfo saveOrder(OrderInfo orderInfo, ShiroUser shiroUser) throws Exception;

    OrderInfo saveEmptyOrder(OrderInfo orderInfo, ShiroUser shiroUser) throws Exception;

    /**
     * @description: 删除货运单
     * @param: orderId 货运单id
     * @return: boolean 是否成功
     * @author: wzp
     * @date: 2020/5/6
     */
    void deleteOrder(long orderId, ShiroUser shiroUser) throws Exception;

//    /**
//     * @description: 审核
//     * @param: orderId 运输单id
//     * @param: shiroUser
//     * @return: void
//     * @author: wzp
//     * @date: 2020/5/8
//     */
//    void audit(long orderId, ShiroUser shiroUser) throws Exception;

    /**
     * @description: 取消
     * @param: orderId 运输单id
     * @param: shiroUser
     * @return: void
     * @author: wzp
     * @date: 2020/5/8
     */
    void cancel(long orderId, String msg, ShiroUser shiroUser) throws Exception;

    /**
     * @description: 发货
     * @param: orderId 运输单id
     * @param: shiroUser
     * @return: void
     * @author: wzp
     * @date: 2020/5/8
     */
    void shipments(long orderId, String credentials, String remark, ShiroUser shiroUser) throws Exception;

    /**
     * @description: 收货
     * @param: orderId 运输单id
     * @param: shiroUser
     * @return: void
     * @author: wzp
     * @date: 2020/5/8
     */
    OrderInfo receiving(long orderId, String credentials, ShiroUser shiroUser) throws Exception;

    /**
     * @description: 定价
     * @param: orderId 运输单id
     * @param: shiroUser
     * @return: void
     * @author: wzp
     * @date: 2020/5/8
     */
    void pricing(long orderId, long locationId, BigDecimal price, BigDecimal actualAmount, String msg, String pageNo, ShiroUser shiroUser) throws Exception;

//    /**
//     * @description: 核算
//     * @param: orderId 运输单id
//     * @param: shiroUser
//     * @return: void
//     * @author: wzp
//     * @date: 2020/5/8
//     */
//    void checkComputation(long orderId, BigDecimal actualAmount, ShiroUser shiroUser) throws Exception;

    /**
     * @description: 完成
     * @param: orderId 运输单id
     * @param: shiroUser
     * @return: void
     * @author: wzp
     * @date: 2020/5/8
     */
    void complete(long orderId, String credentials, ShiroUser shiroUser) throws Exception;

    void archive(long orderId, ShiroUser shiroUser) throws Exception;

    /**
     * @description: 驳回
     * @param: orderId 运输单id
     * @param: shiroUser
     * @return: void
     * @author: wzp
     * @date: 2020/5/8
     */
    void rejected(long orderId, String message, ShiroUser shiroUser) throws Exception;

    /**
     * @description: 根据采购单创建货运单信息
     * @param: supOrderNo 采购单号
     * @return: OrderInfo 货运单信息
     * @author: wzp
     * @date: 2020/5/8
     */
    OrderInfo matchSupOrderInfo(String supOrderNo);

    List<SelectMap> selectMap(String key, long createId, int lineType);

    OrderCountStatisticVo countStatistic(String type) throws ParseException;

    List<OrderStatisticVo> queryDate(String type, Date startTime, Date endTime);

}
